if exists (select * from sys.sysobjects where xtype='p' and id=OBJECT_ID('usp_ProductSync'))
begin
	drop proc usp_ProductSync
end

go
create proc usp_ProductSync
as
begin
	insert into Bas_Product(ProductID,CateCode,ProductCode,ProductName,Alias,Standard,Unit,Other,Company,Description,Deleted)
	select newid(),ReservedField01,sku,Descr_C,Descr_C,Descr_E,Alternate_SKU5,approvalNo,'777',ReservedField08,0 from [UFINTERFACE].[ufInterface].dbo.ERP_BAS_SKU where customerID = '77' and ReservedField01 like '01%'
	and sku not in(select ProductCode from Bas_Product)

	insert into Bas_Product(ProductID,CateCode,ProductCode,ProductName,Alias,Standard,Unit,Other,Company,Description,Deleted)
	select newid(),ReservedField01,sku,Descr_C,Descr_C,Descr_E,Alternate_SKU5,approvalNo,'777',ReservedField08,0 from [UFINTERFACE].[ufInterface].dbo.ERP_BAS_SKU where customerID = '888' and ReservedField01 like '01%'
	and sku not in(select ProductCode from Bas_Product)

	update Bas_Product set CateCodeEx = b.CateCode
	from Bas_Product a
	inner join Import_cate b on a.CateCode = b.cateex
end

go

exec usp_ProductSync